package com.tedu.bill.demo4;

/**
 * Author：毕龙
 * Date: 2024/5/24 15:14
 */
public class Train extends Thread{
    private static int ticket;//火车票

    @Override
    public void run() {
        while (true){
            //当票卖了120张时 退出循环
            if(ticket == 120){
                break;
            }
           try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }


            ticket ++;

            System.out.println(Thread.currentThread().getName()+"第"+ticket+"张票卖出");
        }
    }
}
